﻿using DropBoxClient.Entities;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;

namespace DropBoxClient.Tests
{
    [TestClass]
    public class TestInitializer
    {        
        [AssemblyInitialize]
        public static void Init(TestContext context)
        {
            var accessToken = ConfigurationManager.AppSettings["AccessToken"];
            var root = StringConstants.SandboxRoot;
            var client = new OAuth2Client(accessToken);
            var dataDir = ConfigurationManager.AppSettings["DataDirectory"];
            var notesFilePath = Path.Combine(dataDir, "Notes.txt");
            var imageFilePath = Path.Combine(dataDir, "Image.png");
            client.CreateFolder(root, "Test");
            client.CreateFolder(root, "Test/Test2");
            client.PutFiles(root, "Test/Notes.txt", notesFilePath);
            client.PutFiles(root, "Test/Image.png", imageFilePath);
        }

        [AssemblyCleanup]
        public static void Cleanup()
        {
            var accessToken = ConfigurationManager.AppSettings["AccessToken"];
            var root = StringConstants.SandboxRoot;
            var client = new OAuth2Client(accessToken);
            client.Delete(root, "Test");
        }
    }
}
